package com.example.spring.security.demo.controller;

import com.example.spring.security.demo.entity.ResponseResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName HelloController
 * @Description
 * @Author lichuanqi
 * @Date 2022/5/12 19:30
 * @Version 1.0
 **/
@RestController
public class HelloController {

    @RequestMapping("/hello")
    public String hello(){
        return "hello";
    }


    @PreAuthorize("hasAnyAuthority('system:test')")
    @RequestMapping("/system/test")
    public String systemTest(){
        return "test";
    }


    @PreAuthorize("@ex.hasAuthority('system:test')")
    @RequestMapping("/ex/test")
    public String exTest(){
        return "test";
    }

    @RequestMapping("/testCors")
    public ResponseResult testCors(){
        return new ResponseResult(200,"success");
    }
}
